﻿@using doufu.Model.ViewModel
@model List<UserPermission>
<h2>@Request["userid"]</h2>
<script type="text/javascript">
    function SavePermission(ths, userid, permissionid) {
        $.post('@Url.Action("SaveUserPermission")', { userId: userid, permissionId: permissionid }, function (r) {
            if (r == 1) {
                var text = $(ths);
                text.text(text.text() == "添加" ? "取消" : "添加");
            }
            else {
                alert(r);
            }
        });
    }
</script>
<ul>
    @foreach (var entity in Model)
    {
        <li>@entity.permission_name <span onclick="SavePermission(this,'@(entity.user_id)','@(entity.permission_id)')" class="hand">@(entity.has_permission==0?"添加":"取消")</span>
        </li>
    }
</ul>
